<template>
  <div class="demo">
    <div class="demo-title">基于 Promise 的异步关闭 (3.0+)</div>
    <div class="demo-content">
      <Popconfirm title="Title" @confirm="confirm" @cancel="cancel">
        <Button type="primary">Open Popconfirm with Promise</Button>
      </Popconfirm>
    </div>
  </div>
</template>

<script lang="ts" setup>
  import Message from '@sscd/message';
  import Button from '@sscd/button';
  import Popconfirm from '@sscd/popconfirm';
  const confirm = (e: MouseEvent) => {
    console.log(e);
    return new Promise((resolve) => {
      setTimeout(() => resolve(true), 3000);
    });
  };
  const cancel = (e: MouseEvent) => {
    console.log(e);
    Message.error('Click on No');
  };
</script>
